package com.ruoyi.control.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.control.dto.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.control.mapper.ElectricityMapper;
import com.ruoyi.control.domain.Electricity;
import com.ruoyi.control.service.IElectricityService;

/**
 * 电力实时Service业务层处理
 *
 * @author ruoyi
 * @date 2024-11-09
 */
@Service
public class ElectricityServiceImpl extends ServiceImpl<ElectricityMapper, Electricity> implements IElectricityService //修改
{
    @Autowired
    private ElectricityMapper electricityMapper;

    /**
     * 查询电力实时
     *
     * @param tagName 电力实时主键
     * @return 电力实时
     */
    @Override
    public Electricity selectElectricityByTagName(String tagName) {
        return electricityMapper.selectElectricityByTagName(tagName);
    }

    /**
     * 查询电力实时列表
     *
     * @param electricity 电力实时
     * @return 电力实时
     */
    @Override
    public List<Electricity> selectElectricityList(Electricity electricity) {
        return electricityMapper.selectElectricityList(electricity);
    }

    /**
     * 新增电力实时
     *
     * @param electricity 电力实时
     * @return 结果
     */
    @Override
    public int insertElectricity(Electricity electricity) {
        return electricityMapper.insertElectricity(electricity);
    }

    /**
     * 修改电力实时
     *
     * @param electricity 电力实时
     * @return 结果
     */
    @Override
    public int updateElectricity(Electricity electricity) {
        electricity.setUpdateTime(DateUtils.getNowDate());
        return electricityMapper.updateElectricity(electricity);
    }

    /**
     * 批量删除电力实时
     *
     * @param tagNames 需要删除的电力实时主键
     * @return 结果
     */
    @Override
    public int deleteElectricityByTagNames(String[] tagNames) {
        return electricityMapper.deleteElectricityByTagNames(tagNames);
    }

    /**
     * 删除电力实时信息
     *
     * @param tagName 电力实时主键
     * @return 结果
     */
    @Override
    public int deleteElectricityByTagName(String tagName) {
        return electricityMapper.deleteElectricityByTagName(tagName);
    }

    /**
     * lqx
     * 处理数据方法类
     */
    public Electricity processData(Electricity electricity, int CT) {
        //提取tag_name关键字
        // 查找最后一个下划线的索引
        int lastIndex = electricity.getTagName().lastIndexOf("_");
        // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
        if (lastIndex != -1) {
            electricity.setTagName(electricity.getTagName().substring(lastIndex + 1));
        } else {
            System.out.println("字符串中没有下划线");
        }
        switch (electricity.getTagName()) {
            case "Analog1":
                Float analog1Value = Float.valueOf((electricity.getValue()));
                electricity.setValue(String.format("%.3f", (analog1Value * 0.01 * CT)));
                break;
            case "Analog2":
                Float analog2Value = Float.valueOf((electricity.getValue()));
                electricity.setValue(String.format("%.3f", (analog2Value * 0.01 * CT)));
                break;
            case "Analog3":
                Float analog3Value = Float.valueOf((electricity.getValue()));
                electricity.setValue(String.format("%.3f", (analog3Value * 0.01 * CT)));
                break;
            case "Analog7":
                Float analog7Value = Float.valueOf((electricity.getValue()));
                electricity.setValue(String.format("%.3f", (analog7Value * 0.01)));
                break;
            case "Analog8":
                Float analog8Value = Float.valueOf((electricity.getValue()));
                electricity.setValue(String.format("%.3f", (analog8Value * 0.01)));
                break;
            case "Analog10":
                Float analog10Value = Float.valueOf((electricity.getValue()));
                electricity.setValue(String.format("%.3f", (analog10Value * 0.01)));
                break;
            case "Analog11":
                Float analog11Value = Float.valueOf((electricity.getValue()));
                electricity.setValue(String.format("%.3f", (analog11Value * 0.1 * CT)));
                break;
            case "Analog12":
                Float analog12Value = Float.valueOf((electricity.getValue()));
                electricity.setValue(String.format("%.3f", (analog12Value * 0.1 * CT)));
                break;
            case "Analog13":
                Float analog13Value = Float.valueOf((electricity.getValue()));
                electricity.setValue(String.format("%.3f", (analog13Value * 0.01)));
                break;
            default:
                break;
        }
        return electricity;
    }

    /**
     * lqx
     * 处理地面变电所数据方法类
     */
    public String processUnderData(Electricity electricity, int CT, ElectricityDto electricityDto, String tagName) {
        String returnData = electricity.getValue();
        switch (tagName) {
            case "Analog1":
                Float analog1Value = Float.valueOf((electricity.getValue()));
                returnData = String.format("%.2f", (analog1Value * 0.01 * CT));
                electricityDto.setAnalog1(returnData);
                break;
            case "Analog2":
                Float analog2Value = Float.valueOf((electricity.getValue()));
                returnData = String.format("%.2f", (analog2Value * 0.01 * CT));
                electricityDto.setAnalog2(returnData);
                break;
            case "Analog3":
                Float analog3Value = Float.valueOf((electricity.getValue()));
                returnData = String.format("%.2f", (analog3Value * 0.01 * CT));
                electricityDto.setAnalog3(returnData);
                break;
            case "Analog4":
                Float analog4Value = Float.valueOf((electricity.getValue()));
                returnData = String.format("%.2f", (analog4Value * 0.001));
                electricityDto.setAnalog4(returnData);
                break;
            case "Analog5":
                Float analog5Value = Float.valueOf((electricity.getValue()));
                returnData = String.format("%.2f", (analog5Value * 0.001));
                electricityDto.setAnalog5(returnData);
                break;
            case "Analog6":
                Float analog6Value = Float.valueOf((electricity.getValue()));
                returnData = String.format("%.2f", (analog6Value * 0.001));
                electricityDto.setAnalog6(returnData);
                break;
            default:
                break;
        }
        return returnData;
    }

    /**
     * lqx
     * 查询电力实时列表(地面变电所-遥测)
     */
    @Override
    public Electricity selectGroundSubstationConsumption(String tagName) {
        Electricity electricity = electricityMapper.selectGroundSubstationConsumption(tagName);
        //提取tag_name关键字Analog
        // 查找最后一个下划线的索引
        int lastIndex = electricity.getTagName().lastIndexOf("_");
        // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
        if (lastIndex != -1) {
            electricity.setTagName(electricity.getTagName().substring(lastIndex + 1));
        }
        //处理遥测数据
        switch (tagName) {
            case "AH1.":
                electricity = processData(electricity, 300);
                break;
            default:
                electricity = processData(electricity, 100);
                break;
        }
        return electricity;
    }

    /**
     * lqx
     * 查询电力实时列表(地面变电所-遥测)
     */
    @Override
    public List<Electricity> selectGroundSubstationTelemetryList(String tagName) {
        List<Electricity> electricitieyList = electricityMapper.selectGroundSubstationTelemetryList(tagName);
        List<Electricity> collect = electricitieyList.stream().map(electricity -> {
            //提取tag_name关键字Analog
            // 查找最后一个下划线的索引
            int lastIndex = electricity.getTagName().lastIndexOf("_");
            // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
            if (lastIndex != -1) {
                electricity.setTagName(electricity.getTagName().substring(lastIndex + 1));
            } else {
                System.out.println("字符串中没有下划线");
            }

            //处理遥测数据
            switch (tagName) {
                case "AH1.":
                    electricity = processData(electricity, 300);
                    break;
                case "AH2.":
                    electricity = processData(electricity, 40);
                    break;
                case "AH3.":
                    electricity = processData(electricity, 40);
                    break;
                case "AH4.":
                    electricity = processData(electricity, 40);
                    break;
                case "AH5.":
                    electricity = processData(electricity, 40);
                    break;
                case "AH10.":
                    electricity = processData(electricity, 40);
                    break;
                case "AH13.":
                    electricity = processData(electricity, 40);
                    break;
                default:
                    electricity = processData(electricity, 100);
                    break;
            }
            return electricity;
        }).collect(Collectors.toList());
        return collect;
    }

    /**
     * lqx
     * 查询电力实时列表(地面变电所-遥信)
     */
    @Override
    public List<Electricity> selectGroundSubstationSignalingList(String tagName) {
        List<Electricity> electricitieyList = electricityMapper.selectGroundSubstationTelemetryList(tagName);
        List<Electricity> collect = electricitieyList.stream().map(electricity -> {
            //提取tag_name关键字Status
            Pattern pattern = Pattern.compile("Status\\d+_\\d+");
            Matcher matcher = pattern.matcher(electricity.getTagName());
            if (matcher.find()) {
                String result = matcher.group();
                electricity.setTagName(result);
            }
//            //处理遥测数据
//            switch (tagName) {
//                case "AH1.":
//                    electricity = processData(electricity, 300);
//                    break;
//                case "AH2.":
//                    electricity = processData(electricity, 40);
//                    break;
//                case "AH3.":
//                    electricity = processData(electricity, 40);
//                    break;
//                case "AH4.":
//                    electricity = processData(electricity, 40);
//                    break;
//                case "AH5.":
//                    electricity = processData(electricity, 40);
//                    break;
//                case "AH10.":
//                    electricity = processData(electricity, 40);
//                    break;
//                case "AH13.":
//                    electricity = processData(electricity, 40);
//                    break;
//                default:
//                    electricity = processData(electricity, 100);
//                    break;
//            }
            return electricity;
        }).collect(Collectors.toList());
        return collect;
    }

    /**
     * lqx
     * 查询电力实时列表(地下高压变电所1-遥测)
     */
    @Override
    public List<Electricity> selectUndergroundSubstationH1TelemetryList(String tagName) {
        List<Electricity> electricitieyList = electricityMapper.selectGroundSubstationTelemetryList(tagName);
        List<Electricity> collect = electricitieyList.stream().map(electricity -> {
            //提取tag_name关键字Analog
            // 查找最后一个下划线的索引
            int lastIndex = electricity.getTagName().lastIndexOf("_");
            // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
            if (lastIndex != -1) {
                electricity.setTagName(electricity.getTagName().substring(lastIndex + 1));
            } else {
                System.out.println("字符串中没有下划线");
            }
            return electricity;
        }).collect(Collectors.toList());
        return collect;
    }

    /**
     * lqx
     * 查询电力实时列表(地下高压变电所2-遥测)
     */
    @Override
    public List<Electricity> selectUndergroundSubstationH2TelemetryList(String tagName) {
        List<Electricity> electricitieyList = electricityMapper.selectGroundSubstationTelemetryList(tagName);
        List<Electricity> collect = electricitieyList.stream().map(electricity -> {
            //提取tag_name关键字Analog
            // 查找最后一个下划线的索引
            int lastIndex = electricity.getTagName().lastIndexOf("_");
            // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
            if (lastIndex != -1) {
                electricity.setTagName(electricity.getTagName().substring(lastIndex + 1));
            } else {
                System.out.println("字符串中没有下划线");
            }
            //处理遥测数据
            switch (electricity.getTagName()) {
                case "Analog0":
                    Float analog0Value = Float.valueOf((electricity.getValue()));
                    electricity.setValue(String.format("%.3f", (analog0Value * 0.1)));
                    break;
                case "Analog1":
                    Float analog1Value = Float.valueOf((electricity.getValue()));
                    electricity.setValue(String.format("%.3f", (analog1Value * 0.1)));
                    break;
                case "Analog2":
                    Float analog2Value = Float.valueOf((electricity.getValue()));
                    electricity.setValue(String.format("%.3f", (analog2Value * 0.1)));
                    break;
                case "Analog3":
                    Float analog3Value = Float.valueOf((electricity.getValue()));
                    electricity.setValue(String.format("%.3f", (analog3Value * 0.4)));
                    ;
                case "Analog4":
                    Float analog4Value = Float.valueOf((electricity.getValue()));
                    electricity.setValue(String.format("%.3f", (analog4Value * 0.01)));
                    break;
                case "Analog5":
                    Float analog5Value = Float.valueOf((electricity.getValue()));
                    electricity.setValue(String.format("%.3f", (analog5Value * 0.01)));
                    break;
                case "Analog6":
                    Float analog6Value = Float.valueOf((electricity.getValue()));
                    electricity.setValue(String.format("%.3f", (analog6Value * 0.4)));
                    break;
                case "Analog7":
                    Float analog7Value = Float.valueOf((electricity.getValue()));
                    electricity.setValue(String.format("%.3f", (analog7Value * 0.4)));

                    break;
                case "Analog8":
                    Float analog8Value = Float.valueOf((electricity.getValue()));
                    electricity.setValue(String.format("%.3f", (analog8Value * 0.01)));
                    break;
                case "Analog9":
                    Float analog9Value = Float.valueOf((electricity.getValue()));
                    electricity.setValue(String.format("%.3f", (analog9Value * 0.01)));
                    break;
                default:
                    break;
            }
            return electricity;
        }).collect(Collectors.toList());
        return collect;
    }

    /**
     * lqx
     * 查询电力实时列表(地面变电所-遥测+遥信)
     */
    @Override
    public List<ElectricityDto> selectGroundSubstationList() {
        //循环每个设备查找他的值并进行处理
        List<ElectricityDto> electricityDtoList = new ArrayList<ElectricityDto>();
        for (int i = 1; i <= 32; i++) {
            if (i == 12 || i == 17 || i == 21) {
                continue;
            } else {
                String tagName = "AH" + i + ".";
                List<Electricity> electricitiyList = electricityMapper.selectGroundSubstationList(tagName);
                ElectricityDto electricityDto = new ElectricityDto();
                //处理数据
                List<Electricity> collect = electricitiyList.stream().map(electricity -> {
                    //处理遥信数据
                    //提取tag_name关键字Status
                    Pattern pattern = Pattern.compile("Status\\d+_\\d+");
                    Matcher matcher = pattern.matcher(electricity.getTagName());
                    if (matcher.find()) {
                        String result = matcher.group();
                        electricity.setTagName(result);
                        switch (electricity.getTagName()) {
                            case "Status0_0":
                                electricityDto.setStatus0_0(electricity.getValue());
                                break;
                            case "Status1_2":
                                electricityDto.setStatus1_2(electricity.getValue());
                                break;
                            case "Status0_1":
                                electricityDto.setStatus0_1(electricity.getValue());
                                break;
                            case "Status0_2":
                                electricityDto.setStatus0_2(electricity.getValue());
                                break;
                            case "Status0_3":
                                electricityDto.setStatus0_3(electricity.getValue());
                                break;
                            case "Status2_0":
                                electricityDto.setStatus2_0(electricity.getValue());
                                break;
                            case "Status2_1":
                                electricityDto.setStatus2_1(electricity.getValue());
                                break;
                            case "Status5_0":
                                electricityDto.setStatus5_0(electricity.getValue());
                                break;
                            default:
                                break;
                        }
                    } else {
                        System.out.println("no status");
                    }


                    //处理遥测数据
                    //提取tag_name关键字Analog
                    // 查找最后一个下划线的索引
                    int lastIndex = electricity.getTagName().lastIndexOf("_");
                    // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                    if (lastIndex != -1) {
                        String analogX = electricity.getTagName().substring(lastIndex + 1);
                        electricity.setTagName(analogX);
                        switch (tagName) {
                            case "AH1.":
//                            electricity = processData(electricity, 300);
                                processUnderData(electricity, 300, electricityDto, electricity.getTagName());
                                break;
                            case "AH2.":
//                            electricity = processData(electricity, 40);
                                processUnderData(electricity, 40, electricityDto, electricity.getTagName());
                                break;
                            case "AH3.":
//                            electricity = processData(electricity, 40);
                                processUnderData(electricity, 40, electricityDto, electricity.getTagName());
                                break;
                            case "AH4.":
//                            electricity = processData(electricity, 40);
                                processUnderData(electricity, 40, electricityDto, electricity.getTagName());
                                break;
                            case "AH5.":
//                            electricity = processData(electricity, 40);
                                processUnderData(electricity, 40, electricityDto, electricity.getTagName());
                                break;
                            case "AH10.":
//                            electricity = processData(electricity, 40);
                                processUnderData(electricity, 40, electricityDto, electricity.getTagName());
                                break;
                            case "AH13.":
                                processUnderData(electricity, 40, electricityDto, electricity.getTagName());
//                            electricity = processData(electricity, 40);
                                break;
                            default:
//                            electricity = processData(electricity, 100);
                                processUnderData(electricity, 100, electricityDto, electricity.getTagName());
                                break;
                        }
                    } else {
                        System.out.println("字符串中没有下划线");
                    }

                    return electricity;
                }).collect(Collectors.toList());
                electricityDtoList.add(electricityDto);
            }
        }
        return electricityDtoList;
    }

    /**
     * lqx
     * 查询电力实时列表(地面变电所-状态0_0)
     */
    @Override
    public List<Electricity> listGroundSubstationStatus5_0() {
        return electricityMapper.listGroundSubstationStatus5_0();
    }

    /**
     * lqx
     * 查询电力实时列表(地面变电所-状态0_0)
     */
    @Override
    public List<Electricity> listGroundSubstationStatus0_0() {
        return electricityMapper.listGroundSubstationStatus0_0();
    }

    /**
     * lqx
     * 查询电力实时列表(地下高压变电所-遥测)
     */
    @Override
    public List<ElectricityUnderHDto> listUnderGroundSubstationH() {
        //循环每个设备查找他的值并进行处理
        List<ElectricityUnderHDto> electricityUnderHDtoList = new ArrayList<>();
        for (int i = 1; i <= 11; i++) {
            if (i == 7 || i == 8 || i == 9 || i == 10) {
                //高压一
                String tagName = "G" + i + "高开";
                List<Electricity> electricitiyList = electricityMapper.selectGroundSubstationList(tagName);
                ElectricityUnderHDto electricityUnderHDto = new ElectricityUnderHDto();
                //处理数据
                List<Electricity> collect = electricitiyList.stream().map(electricity -> {
                    //处理遥测数据
                    //提取tag_name关键字Analog
                    // 查找最后一个下划线的索引
                    int lastIndex = electricity.getTagName().lastIndexOf("_");
                    // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                    if (lastIndex != -1) {
                        String analogX = electricity.getTagName().substring(lastIndex + 1);
                        electricity.setTagName(analogX);
                        switch (electricity.getTagName()) {
                            case "Analog0":
                                Float analog0Value = Float.valueOf((electricity.getValue()));
                                electricityUnderHDto.setAnalog0(String.format("%.1f", analog0Value));
                                electricityUnderHDto.setTagName(tagName + electricity.getTagName());
                                break;
                            case "Analog2":
                                Float analog2Value = Float.valueOf((electricity.getValue()));
                                electricityUnderHDto.setAnalog2(String.format("%.1f", analog2Value));
                                electricityUnderHDto.setTagName(tagName + electricity.getTagName());
                                break;
                            case "Analog3":
                                Float analog3Value = Float.valueOf((electricity.getValue()));
                                electricityUnderHDto.setAnalog3(String.format("%.1f", analog3Value));
                                electricityUnderHDto.setTagName(tagName + electricity.getTagName());
                                ;
                            default:
                                break;
                        }
                    } else {
                        System.out.println("字符串中没有下划线");
                    }

                    return electricity;
                }).collect(Collectors.toList());
                electricityUnderHDtoList.add(electricityUnderHDto);
            } else {
                //高压二
                String tagName = "G" + i + "高开";
                List<Electricity> electricitiyList = electricityMapper.selectGroundSubstationList(tagName);
                ElectricityUnderHDto electricityUnderHDto = new ElectricityUnderHDto();
                //处理数据
                List<Electricity> collect = electricitiyList.stream().map(electricity -> {
                    //处理遥测数据
                    //提取tag_name关键字Analog
                    // 查找最后一个下划线的索引
                    int lastIndex = electricity.getTagName().lastIndexOf("_");
                    // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                    if (lastIndex != -1) {
                        String analogX = electricity.getTagName().substring(lastIndex + 1);
                        electricity.setTagName(analogX);
                        switch (electricity.getTagName()) {
                            case "Analog0":
                                Float analog0Value = Float.valueOf((electricity.getValue()));
                                electricityUnderHDto.setAnalog0(String.format("%.1f", (analog0Value * 0.1)));
                                electricityUnderHDto.setTagName(tagName + electricity.getTagName());
                                break;
                            case "Analog2":
                                Float analog2Value = Float.valueOf((electricity.getValue()));
                                electricityUnderHDto.setAnalog2(String.format("%.1f", (analog2Value * 0.1)));
                                electricityUnderHDto.setTagName(tagName + electricity.getTagName());
                                break;
                            case "Analog3":
                                Float analog3Value = Float.valueOf((electricity.getValue()));
                                electricityUnderHDto.setAnalog3(String.format("%.1f", (analog3Value * 0.4)));
                                electricityUnderHDto.setTagName(tagName + electricity.getTagName());
                                ;
                            default:
                                break;
                        }
                    } else {
                        System.out.println("字符串中没有下划线");
                    }

                    return electricity;
                }).collect(Collectors.toList());
                electricityUnderHDtoList.add(electricityUnderHDto);
            }
        }
        return electricityUnderHDtoList;
    }

    /**
     * lqx
     * 查询电力实时列表(地下低压变电所-遥测)
     */
    @Override
    public List<ElectricityUnderLDto> listUnderGroundSubstationL() {
        //循环每个设备查找他的值并进行处理
        List<ElectricityUnderLDto> electricityUnderLDtoList = new ArrayList<>();
        for (int i = 101; i <= 111; i++) {
            if (i == 107 || i == 108 || i == 109 || i == 110) {
                continue;
            } else {
                //K***
                String tagName = "K" + i + "馈电";
                List<Electricity> electricitiyList = electricityMapper.selectGroundSubstationList(tagName);
                ElectricityUnderLDto electricityUnderLDto = new ElectricityUnderLDto();
                //处理数据
                List<Electricity> collect = electricitiyList.stream().map(electricity -> {
                    //处理遥测数据
                    //提取tag_name关键字Analog
                    // 查找最后一个下划线的索引
                    int lastIndex = electricity.getTagName().lastIndexOf("_");
                    // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                    if (lastIndex != -1) {
                        String analogX = electricity.getTagName().substring(lastIndex + 1);
                        electricity.setTagName(analogX);
                        switch (electricity.getTagName()) {
                            case "Analog2":
                                Float analog0Value = Float.valueOf((electricity.getValue()));
                                electricityUnderLDto.setAnalog2(String.format("%.1f", (analog0Value)));
                                electricityUnderLDto.setTagName(tagName + electricity.getTagName());
                                break;
                            case "Analog4":
                                Float analog2Value = Float.valueOf((electricity.getValue()));
                                electricityUnderLDto.setAnalog3(String.format("%.1f", (analog2Value)));
                                electricityUnderLDto.setTagName(tagName + electricity.getTagName());
                                break;
                            case "Analog6":
                                Float analog3Value = Float.valueOf((electricity.getValue()));
                                electricityUnderLDto.setAnalog6(String.format("%.1f", (analog3Value)));
                                electricityUnderLDto.setTagName(tagName + electricity.getTagName());
                                ;
                            default:
                                break;
                        }
                    } else {
                        System.out.println("字符串中没有下划线");
                    }

                    return electricity;
                }).collect(Collectors.toList());
                electricityUnderLDtoList.add(electricityUnderLDto);
            }

        }
        for (int i = 1517; i <= 1526; i++) {
            //K***
            String tagName = "K" + i + "馈电";
            List<Electricity> electricitiyList = electricityMapper.selectGroundSubstationList(tagName);
            ElectricityUnderLDto electricityUnderLDto = new ElectricityUnderLDto();
            //处理数据
            List<Electricity> collect = electricitiyList.stream().map(electricity -> {
                //处理遥测数据
                //提取tag_name关键字Analog
                // 查找最后一个下划线的索引
                int lastIndex = electricity.getTagName().lastIndexOf("_");
                // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                if (lastIndex != -1) {
                    String analogX = electricity.getTagName().substring(lastIndex + 1);
                    electricity.setTagName(analogX);
                    switch (electricity.getTagName()) {
                        case "Analog2":
                            Float analog0Value = Float.valueOf((electricity.getValue()));
                            electricityUnderLDto.setAnalog2(String.format("%.1f", (analog0Value)));
                            electricityUnderLDto.setTagName(tagName + electricity.getTagName());
                            break;
                        case "Analog4":
                            Float analog2Value = Float.valueOf((electricity.getValue()));
                            electricityUnderLDto.setAnalog3(String.format("%.1f", (analog2Value)));
                            electricityUnderLDto.setTagName(tagName + electricity.getTagName());
                            break;
                        case "Analog6":
                            Float analog3Value = Float.valueOf((electricity.getValue()));
                            electricityUnderLDto.setAnalog6(String.format("%.1f", (analog3Value)));
                            electricityUnderLDto.setTagName(tagName + electricity.getTagName());
                            ;
                        default:
                            break;
                    }
                } else {
                    System.out.println("字符串中没有下划线");
                }

                return electricity;
            }).collect(Collectors.toList());
            electricityUnderLDtoList.add(electricityUnderLDto);
        }
        return electricityUnderLDtoList;
    }

    /**
     * lqx
     * 查询电力实时列表(地下变电所L1-状态0_1)
     */
    @Override
    public List<Electricity> listUnderGroundSubstationH1Status0_1() {
        return electricityMapper.listUnderGroundSubstationH1Status0_1();
    }

    /**
     * lqx
     * 查询电力实时列表(地下变电所L2-状态1_6)
     */
    @Override
    public List<Electricity> listUnderGroundSubstationH2Status1_6() {
        return electricityMapper.listUnderGroundSubstationH2Status1_6();
    }

    /**
     * lqx
     * 查询电力实时列表(地下变电所L1-状态2_1)
     */
    @Override
    public List<Electricity> listUnderGroundSubstationL1Status2_1() {
        return electricityMapper.listUnderGroundSubstationL1Status2_1();
    }

    /**
     * lqx
     * 查询电力实时列表(地下变电所-状态5_0)
     */
    @Override
    public List<Electricity> listUnderGroundSubstationStatus5_0() {
        return electricityMapper.listUnderGroundSubstationStatus5_0();
    }


    /**
     * lqx
     * 查询电力实时列表(地面变电所-遥测+遥信 - ch)
     */
    @Override
    public List<GroundElectricityDto> selectGroundElectricityDtoList() {
        List<GroundElectricityDto> groundElectricityDtoList = new ArrayList<>();
        for (int i = 1000; i <= 1010; i++) {
            if (i == 1009) {
                continue;
            } else {
                GroundElectricityDto groundElectricityDto = new GroundElectricityDto();
                String tatName = i + "_";
                List<Electricity> electricityList = electricityMapper.selectGroundSubstationTelemetryList(tatName);
                //处理数据
                List<Electricity> collect = electricityList.stream().map(electricity -> {
                    //处理遥测数据
                    //提取tag_name关键字
                    // 查找最后一个下划线的索引
                    int lastIndex = electricity.getTagName().lastIndexOf("_");
                    // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                    if (lastIndex != -1) {
                        String analogX = electricity.getTagName().substring(lastIndex + 1);
                        switch (analogX) {
                            case "Ia":
                                Float analog1Value = Float.valueOf((electricity.getValue()));
                                groundElectricityDto.setAnalog1(String.format("%.1f", (analog1Value)));
                                break;
                            case "Ib":
                                Float analog2Value = Float.valueOf((electricity.getValue()));
                                groundElectricityDto.setAnalog2(String.format("%.1f", (analog2Value)));
                                break;
                            case "Ic":
                                Float analog3Value = Float.valueOf((electricity.getValue()));
                                groundElectricityDto.setAnalog3(String.format("%.1f", (analog3Value)));
                                break;
                            case "Uab":
                                Float analog4Value = Float.valueOf((electricity.getValue()));
                                groundElectricityDto.setAnalog4(String.format("%.1f", (analog4Value)));
                                break;
                            case "Ubc":
                                Float analog5Value = Float.valueOf((electricity.getValue()));
                                groundElectricityDto.setAnalog5(String.format("%.1f", (analog5Value)));
                                break;
                            case "Uca":
                                Float analog6Value = Float.valueOf((electricity.getValue()));
                                groundElectricityDto.setAnalog6(String.format("%.1f", (analog6Value)));
                                break;
                            case "3UO":
                                Float analog7Value = Float.valueOf((electricity.getValue()));
                                groundElectricityDto.setAnalog7(String.format("%.1f", (analog7Value)));
                                break;
                            case "yggl":
                                Float analog8Value = Float.valueOf((electricity.getValue()));
                                groundElectricityDto.setAnalog8(String.format("%.1f", (analog8Value)));
                                break;
                            case "cos":
                                Float analog9Value = Float.valueOf((electricity.getValue()));
                                groundElectricityDto.setAnalog9(String.format("%.1f", (analog9Value)));
                                break;
                            case "f":
                                Float analog10Value = Float.valueOf((electricity.getValue()));
                                groundElectricityDto.setAnalog10(String.format("%.1f", (analog10Value)));
                                break;
                            case "dlqwz":
                                groundElectricityDto.setStatus1(electricity.getValue());
                                break;
                            case "txgz":
                                groundElectricityDto.setStatus2(electricity.getValue());
                                break;
                            default:
                                break;
                        }
                    } else {
                        System.out.println("字符串中没有下划线");
                    }

                    return electricity;
                }).collect(Collectors.toList());
                groundElectricityDtoList.add(groundElectricityDto);
            }
        }
        return groundElectricityDtoList;
    }

    /**
     * lqx
     * 查询电力实时列表(地下变电所高压-遥测+遥信 - ch)
     */
    @Override
    public List<UnderGroundHElectricityDto> selectUnderGroundHElectricityDtoList() {
        List<UnderGroundHElectricityDto> underGroundHElectricityDtoList = new ArrayList<>();
        for (int i = 1; i <= 7; i++) {
            UnderGroundHElectricityDto underGroundHElectricityDto = new UnderGroundHElectricityDto();
            String tatName = "\\_" + i + "#";
            List<Electricity> electricityList = electricityMapper.selectGroundSubstationTelemetryList(tatName);
            //处理数据
            List<Electricity> collect = electricityList.stream().map(electricity -> {
                //处理遥测数据
                //提取tag_name关键字
                // 查找最后一个下划线的索引
                int lastIndex = electricity.getTagName().lastIndexOf("_");
                // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                if (lastIndex != -1) {
                    String analogX = electricity.getTagName().substring(lastIndex + 1);
                    switch (analogX) {
                        case "Ua":
                            Float analog1Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog1(String.format("%.1f", (analog1Value)));
                            break;
                        case "Ub":
                            Float analog2Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog2(String.format("%.1f", (analog2Value)));
                            break;
                        case "Uc":
                            Float analog3Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog3(String.format("%.1f", (analog3Value)));
                            break;
                        case "Uab":
                            Float analog4Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog4(String.format("%.1f", (analog4Value)));
                            break;
                        case "Ubc":
                            Float analog5Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog5(String.format("%.1f", (analog5Value)));
                            break;
                        case "Uca":
                            Float analog6Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog6(String.format("%.1f", (analog6Value)));
                            break;
                        case "UO":
                            Float analog7Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog7(String.format("%.1f", (analog7Value)));
                            break;
                        case "Ia":
                            Float analog8Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog8(String.format("%.1f", (analog8Value)));
                            break;
                        case "Ic":
                            Float analog9Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog9(String.format("%.1f", (analog9Value)));
                            break;
                        case "P":
                            Float analog10Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog10(String.format("%.1f", (analog10Value)));
                            break;
                        case "IO":
                            Float analog11Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog11(String.format("%.1f", (analog11Value)));
                            break;
                        case "cos":
                            Float analog12Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog12(String.format("%.1f", (analog12Value)));
                            break;
                        case "f":
                            Float analog13Value = Float.valueOf((electricity.getValue()));
                            underGroundHElectricityDto.setAnalog13(String.format("%.1f", (analog13Value)));
                            break;
                        case "ddy":
                            underGroundHElectricityDto.setStatus1(electricity.getValue());
                            break;
                        case "lxgy":
                            underGroundHElectricityDto.setStatus2(electricity.getValue());
                            break;
                        case "glbh":
                            underGroundHElectricityDto.setStatus3(electricity.getValue());
                            break;
                        case "dlbh":
                            underGroundHElectricityDto.setStatus4(electricity.getValue());
                            break;
                        case "bshz":
                            underGroundHElectricityDto.setStatus5(electricity.getValue());
                            break;
                        case "PTdx":
                            underGroundHElectricityDto.setStatus6(electricity.getValue());
                            break;
                        case "lded":
                            underGroundHElectricityDto.setStatus7(electricity.getValue());
                            break;
                        case "ldyd":
                            underGroundHElectricityDto.setStatus8(electricity.getValue());
                            break;
                        case "hzwz":
                            underGroundHElectricityDto.setStatus9(electricity.getValue());
                            break;
                        case "txgz":
                            underGroundHElectricityDto.setStatus10(electricity.getValue());
                            break;
                        default:
                            break;
                    }
                } else {
                    System.out.println("字符串中没有下划线");
                }

                return electricity;
            }).collect(Collectors.toList());
            underGroundHElectricityDtoList.add(underGroundHElectricityDto);
        }
        return underGroundHElectricityDtoList;
    }

    /**
     * lqx
     * 查询电力实时列表(地下变电所低压-遥测+遥信 - ch)
     */
    @Override
    public List<UnderGroundLElectricityDto> selectUnderGroundLElectricityDtoList() {
        List<UnderGroundLElectricityDto> underGroundLElectricityDtoList = new ArrayList<>();
        for (int i = 10; i <= 20; i++) {
            if (i == 16) {
                continue;
            } else {
                UnderGroundLElectricityDto underGroundLElectricityDto = new UnderGroundLElectricityDto();
                String tatName = "\\_" + i + "_";
                List<Electricity> electricityList = electricityMapper.selectGroundSubstationTelemetryList(tatName);
                //处理数据
                List<Electricity> collect = electricityList.stream().map(electricity -> {
                    //处理遥测数据
                    //提取tag_name关键字
                    // 查找最后一个下划线的索引
                    int lastIndex = electricity.getTagName().lastIndexOf("_");
                    // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                    if (lastIndex != -1) {
                        String analogX = electricity.getTagName().substring(lastIndex + 1);
                        switch (analogX) {
                            case "Uca":
                                Float analog1Value = Float.valueOf((electricity.getValue()));
                                underGroundLElectricityDto.setAnalog1(String.format("%.1f", (analog1Value)));
                                break;
                            case "Ia":
                                Float analog2Value = Float.valueOf((electricity.getValue()));
                                underGroundLElectricityDto.setAnalog2(String.format("%.1f", (analog2Value)));
                                break;
                            case "Ib":
                                Float analog3Value = Float.valueOf((electricity.getValue()));
                                underGroundLElectricityDto.setAnalog3(String.format("%.1f", (analog3Value)));
                                break;
                            case "Ic":
                                Float analog4Value = Float.valueOf((electricity.getValue()));
                                underGroundLElectricityDto.setAnalog4(String.format("%.1f", (analog4Value)));
                                break;
                            case "sy":
                                underGroundLElectricityDto.setStatus1(electricity.getValue());
                                break;
                            case "gl":
                                underGroundLElectricityDto.setStatus2(electricity.getValue());
                                break;
                            case "ld":
                                underGroundLElectricityDto.setStatus3(electricity.getValue());
                                break;
                            case "gz":
                                underGroundLElectricityDto.setStatus4(electricity.getValue());
                                break;
                            case "hwz":
                                underGroundLElectricityDto.setStatus5(electricity.getValue());
                                break;
                            default:
                                break;
                        }
                    } else {
                        System.out.println("字符串中没有下划线");
                    }

                    return electricity;
                }).collect(Collectors.toList());
                underGroundLElectricityDtoList.add(underGroundLElectricityDto);
            }
        }
        return underGroundLElectricityDtoList;
    }

    /**
     * lqx
     * 查询电力实时列表(地面变电所-遥测+遥信 - chReal)
     */
    @Override
    public List<CHGroundElectricityDto> selectCHGroundElectricityDtoList() {
        List<CHGroundElectricityDto> chGroundElectricityDtoList = new ArrayList<>();
        for (int i = 14; i <= 25; i++) {

            CHGroundElectricityDto chGroundElectricityDto = new CHGroundElectricityDto();
            String tatName ="地面变电所" + i + "#";
            List<Electricity> electricityList = electricityMapper.selectGroundSubstationTelemetryList(tatName);
            //处理数据
            List<Electricity> collect = electricityList.stream().map(electricity -> {
                //处理遥测数据
                //提取tag_name关键字
                // 查找最后一个下划线的索引
                int lastIndex = electricity.getTagName().lastIndexOf("_");
                // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                if (lastIndex != -1) {
                    String analogX = electricity.getTagName().substring(lastIndex + 1);
                    switch (analogX) {
                        case "Ua":
                            double analog1Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog1(String.format("%.2f", (analog1Value)));
                            break;
                        case "Ub":
                            double analog2Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog2(String.format("%.2f", (analog2Value)));
                            break;
                        case "Uc":
                            double analog3Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog3(String.format("%.2f", (analog3Value)));
                            break;
                        case "Uab":
                            double analog4Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog4(String.format("%.2f", (analog4Value)));
                            break;
                        case "Ubc":
                            double analog5Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog5(String.format("%.2f", (analog5Value)));
                            break;
                        case "Uca":
                            double analog6Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog6(String.format("%.2f", (analog6Value)));
                            break;
                        case "Ia":
                            double analog7Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog7(String.format("%.2f", (analog7Value)));
                            break;
                        case "Ic":
                            double analog8Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog8(String.format("%.2f", (analog8Value)));
                            break;
                        case "P":
                            double analog9Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog9(String.format("%.2f", (analog9Value)));
                            break;
                        case "Q":
                            double analog10Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog10(String.format("%.2f", (analog10Value)));
                            break;
                        case "cos":
                            double analog11Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog11(String.format("%.2f", (analog11Value)));
                            break;
                        case "f":
                            double analog12Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundElectricityDto.setAnalog12(String.format("%.2f", (analog12Value)));
                            break;
                        case "低电压":
                            chGroundElectricityDto.setStatus1(electricity.getValue());
                            break;
                        case "过电压":
                            chGroundElectricityDto.setStatus2(electricity.getValue());
                            break;
                        case "过流保护":
                            chGroundElectricityDto.setStatus3(electricity.getValue());
                            break;
                        case "短路保护":
                            chGroundElectricityDto.setStatus4(electricity.getValue());
                            break;
                        case "闭锁合闸":
                            chGroundElectricityDto.setStatus5(electricity.getValue());
                            break;
                        case "手车运行位置":
                            chGroundElectricityDto.setStatus6(electricity.getValue());
                            break;
                        case "手车实验位置":
                            chGroundElectricityDto.setStatus7(electricity.getValue());
                            break;
                        case "开关合位":
                            chGroundElectricityDto.setStatus9(electricity.getValue());
                            break;
                        default:
                            break;
                    }
                } else {
                    System.out.println("字符串中没有下划线");
                }

                return electricity;
            }).collect(Collectors.toList());
            chGroundElectricityDtoList.add(chGroundElectricityDto);
        }
        return chGroundElectricityDtoList;
    }


    /**
     * lqx
     * 查询电力实时列表(地面变电所新增-遥测+遥信 - chReal)
     */
    @Override
    public List<CHGroundNewElectricityDto> selectCHGroundNewElectricityDtoList() {
        List<CHGroundNewElectricityDto> chGroundNewElectricityDtoList = new ArrayList<>();
        for (int i = 1; i <= 13; i++) {
            CHGroundNewElectricityDto chGroundNewElectricityDto = new CHGroundNewElectricityDto();
            String tatName ="地面变电所" + i + "#";
            List<Electricity> electricityList = electricityMapper.selectGroundSubstationTelemetryList(tatName);
            //处理数据
            List<Electricity> collect = electricityList.stream().map(electricity -> {
                //处理遥测数据
                //提取tag_name关键字
                // 查找最后一个下划线的索引
                int lastIndex = electricity.getTagName().lastIndexOf("_");
                // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                if (lastIndex != -1) {
                    String analogX = electricity.getTagName().substring(lastIndex + 1);
                    switch (analogX) {
                        case "Uab":
                            double analog1Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundNewElectricityDto.setAnalog1(String.format("%.2f", (analog1Value)));
                            break;
                        case "Ubc":
                            double analog2Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundNewElectricityDto.setAnalog2(String.format("%.2f", (analog2Value)));
                            break;
                        case "Uca":
                            double analog3Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundNewElectricityDto.setAnalog3(String.format("%.2f", (analog3Value)));
                            break;
                        case "Ia":
                            double analog4Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundNewElectricityDto.setAnalog4(String.format("%.2f", (analog4Value)));
                            break;
                        case "Ic":
                            double analog5Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundNewElectricityDto.setAnalog5(String.format("%.2f", (analog5Value)));
                            break;
                        case "P":
                            double analog6Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundNewElectricityDto.setAnalog6(String.format("%.2f", (analog6Value)));
                            break;
                        case "Q":
                            double analog7Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundNewElectricityDto.setAnalog7(String.format("%.2f", (analog7Value)));
                            break;
                        case "cos":
                            double analog8Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundNewElectricityDto.setAnalog8(String.format("%.2f", (analog8Value)));
                            break;
                        case "f":
                            double analog9Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chGroundNewElectricityDto.setAnalog9(String.format("%.2f", (analog9Value)));
                            break;
                        case "低电压":
                            chGroundNewElectricityDto.setStatus1(electricity.getValue());
                            break;
                        case "过电压":
                            chGroundNewElectricityDto.setStatus2(electricity.getValue());
                            break;
                        case "过流保护":
                            chGroundNewElectricityDto.setStatus3(electricity.getValue());
                            break;
                        case "短路保护":
                            chGroundNewElectricityDto.setStatus4(electricity.getValue());
                            break;
                        case "闭锁合闸":
                            chGroundNewElectricityDto.setStatus5(electricity.getValue());
                            break;
                        case "手车运行位置":
                            chGroundNewElectricityDto.setStatus6(electricity.getValue());
                            break;
                        case "手车实验位置":
                            chGroundNewElectricityDto.setStatus7(electricity.getValue());
                            break;
                        case "开关合位":
                            chGroundNewElectricityDto.setStatus9(electricity.getValue());
                            break;
                        default:
                            break;
                    }
                } else {
                    System.out.println("字符串中没有下划线");
                }

                return electricity;
            }).collect(Collectors.toList());
            chGroundNewElectricityDtoList.add(chGroundNewElectricityDto);
        }
        return chGroundNewElectricityDtoList;
    }

    /**
     * lqx
     * 查询电力实时列表(地下变电所高压-遥测+遥信 - chReal)
     */
    @Override
    public List<CHUnderGroundHElectricityDto> selectCHUnderGroundHElectricityDtoList() {
        List<CHUnderGroundHElectricityDto> chUnderGroundHElectricityDtoList = new ArrayList<>();
        for (int i = 1; i <= 15; i++) {
            if (i == 3 || i == 4){
                continue;
            }
            CHUnderGroundHElectricityDto chUnderGroundHElectricityDto = new CHUnderGroundHElectricityDto();
            String tatName ="中央变电所G" + i + "#";
            List<Electricity> electricityList = electricityMapper.selectGroundSubstationTelemetryList(tatName);
            //处理数据
            List<Electricity> collect = electricityList.stream().map(electricity -> {
                //处理遥测数据
                //提取tag_name关键字
                // 查找最后一个下划线的索引
                int lastIndex = electricity.getTagName().lastIndexOf("_");
                // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                if (lastIndex != -1) {
                    String analogX = electricity.getTagName().substring(lastIndex + 1);
                    switch (analogX) {
                        case "Ua":
                            double analog1Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chUnderGroundHElectricityDto.setAnalog1(String.format("%.1f", (analog1Value)));
                            break;
                        case "Ub":
                            double analog2Value = Double.valueOf((electricity.getValue())) * 0.01;
                            chUnderGroundHElectricityDto.setAnalog2(String.format("%.1f", (analog2Value)));
                            break;
                        case "Ia":
                            Float analog3Value = Float.valueOf((electricity.getValue()));
                            chUnderGroundHElectricityDto.setAnalog3(String.format("%.1f", (analog3Value)));
                            break;
                        case "P":
                            Float analog4Value = Float.valueOf((electricity.getValue()));
                            chUnderGroundHElectricityDto.setAnalog4(String.format("%.1f", (analog4Value)));
                            break;
                        default:
                            break;
                    }
                } else {
                    System.out.println("字符串中没有下划线");
                }

                return electricity;
            }).collect(Collectors.toList());
            chUnderGroundHElectricityDtoList.add(chUnderGroundHElectricityDto);
        }
        return chUnderGroundHElectricityDtoList;
    }

    /**
     * lqx
     * 查询电力实时列表(地下变电所低压-遥测+遥信 - chReal)
     */
    @Override
    public List<CHUnderGroundLElectricityDto> selectCHUnderGroundLElectricityDtoList() {
        List<CHUnderGroundLElectricityDto> chUnderGroundLElectricityDtoList = new ArrayList<>();
        for (int i = 1; i <= 21; i++) {
            CHUnderGroundLElectricityDto chUnderGroundLElectricityDto = new CHUnderGroundLElectricityDto();
            String tatName ="中央变电所D" + i + "#";
            List<Electricity> electricityList = electricityMapper.selectGroundSubstationTelemetryList(tatName);
            //处理数据
            List<Electricity> collect = electricityList.stream().map(electricity -> {
                //处理遥测数据
                //提取tag_name关键字
                // 查找最后一个下划线的索引
                int lastIndex = electricity.getTagName().lastIndexOf("_");
                // 如果找到了下划线，则截取从下划线之后到字符串末尾的部分
                if (lastIndex != -1) {
                    String analogX = electricity.getTagName().substring(lastIndex + 1);
                    switch (analogX) {
                        case "Ia":
                            Float analog1Value = Float.valueOf((electricity.getValue()));
                            chUnderGroundLElectricityDto.setAnalog1(String.format("%.1f", (analog1Value)));
                            break;
                        case "Ib":
                            Float analog2Value = Float.valueOf((electricity.getValue()));
                            chUnderGroundLElectricityDto.setAnalog2(String.format("%.1f", (analog2Value)));
                            break;
                        case "Ic":
                            Float analog3Value = Float.valueOf((electricity.getValue()));
                            chUnderGroundLElectricityDto.setAnalog3(String.format("%.1f", (analog3Value)));
                            break;
                        default:
                            break;
                    }
                } else {
                    System.out.println("字符串中没有下划线");
                }

                return electricity;
            }).collect(Collectors.toList());
            chUnderGroundLElectricityDtoList.add(chUnderGroundLElectricityDto);
        }
        return chUnderGroundLElectricityDtoList;
    }
}
